/**
 * @File name: modules/object.c
 * @Synopsis:
 * @Author: xing.dai@aliyun.com
 * @Version: 0.0.1
 * @Date: 2018-08-28 13:15
 */

#include "object.h"
#include "static_pool.h"
#include "os_api.h"


list_t _object_tree[OBJECT_CLASS_MAX];

list_t *get_object_list(object_type_e type)
{
    return &_object_tree[type];
}

/**
 * @Synopsis
 *
 * @Param object
 *
 * @Returns
 */
int object_init(object_t *object, object_type_e type, char *name)
{
    list_t *object_list;
    os_critial_alloc();

    object_list = get_object_list(type);
    object->name = name;
    object->type = type;

    os_enter_critical();
    list_add(object_list, &(object->node));
    os_exit_critical();

    return 0;
}


